package com.pds.web.testOrganizationInfo.controller;

import com.pds.common.core.controller.BaseController;
import com.pds.common.core.domain.R;
import com.pds.common.core.page.TableDataInfo;
import com.pds.web.operationLog.annotation.OprLog;
import com.pds.web.testOrganizationInfo.domain.PdsTestOrganizationRange;
import com.pds.web.testOrganizationInfo.dto.OrganizationRangeDTO;
import com.pds.web.testOrganizationInfo.service.PdsTestOrganizationRangeService;
import com.pds.web.testOrganizationInfo.vo.LargeCategoryVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.*;
import javax.annotation.Resource;
import java.util.List;

/**
 * 检测机构标准范围表
 *
 * @author srf sunlightcs@gmail.com
 * @since 1.0.0 2024-03-11
 */
@RestController
@RequestMapping("/organizationRange")
@Api(tags="检测机构标准范围表")
public class PdsTestOrganizationRangeController extends BaseController {
    @Resource
    private PdsTestOrganizationRangeService pdsTestOrganizationRangeService;

    /**
     * 分页查询标准范围
     *
     *   pageNum/pageSize分页字段
     *   筛选条件字段
     * @return 查询结果
     */
    @ApiOperation("分页查询标准范围")
    @GetMapping("/page")
    public TableDataInfo pageOrganizationRange(PdsTestOrganizationRange pdsTestOrganizationRange){
        startPage();
        List<LargeCategoryVO> list = pdsTestOrganizationRangeService.selectList(pdsTestOrganizationRange);
        return getDataTable(list);
    }

    /**
     * 查询标准范围列表
     *
     *   筛选条件字段
     * @return 查询结果
     */
    @ApiOperation("查询标准范围列表")
    @GetMapping("/list")
    public R<List<LargeCategoryVO>> listOrganizationRange(PdsTestOrganizationRange pdsTestOrganizationRange){
        List<LargeCategoryVO> list = pdsTestOrganizationRangeService.selectList(pdsTestOrganizationRange);
        return R.ok(list);
    }

    /**
     * 根据ID查询标准范围
     *
     * @param id 主键
     * @return 单条数据
     */
    @ApiOperation("标准范围详情")
    @GetMapping("/queryById/{id}")
    public R<PdsTestOrganizationRange> queryOrganizationRangeById(@PathVariable("id")Long id) {
        return R.ok(pdsTestOrganizationRangeService.queryById(id));
    }

    /**
     * 创建标准范围
     * @param organizationRangeDTO 记录
     * @return 标准范围记录
     */
    @OprLog(content = "创建标准范围")
    @ApiOperation("创建标准范围")
    @PostMapping("/add")
    public R<Integer> addOrganizationRange(@RequestBody OrganizationRangeDTO organizationRangeDTO){
        return R.ok(pdsTestOrganizationRangeService.insert(organizationRangeDTO));
    }

    /**
     * 修改标准范围
     * @param organizationRangeDTO 记录
     * @return 成功标识
     */
    @ApiOperation("修改标准范围")
    @PutMapping("/edit")
    public R<Integer> editOrganizationRange(@RequestBody OrganizationRangeDTO organizationRangeDTO){
        return R.ok(pdsTestOrganizationRangeService.update(organizationRangeDTO));
    }

    /**
     * 根据ID删除标准范围
     *
     * @param ids 主键
     * @return 删除是否成功
     */
    @ApiOperation("删除标准范围")
    @DeleteMapping("/delete")
    public R<Integer> deleteOrganizationRangeById(@RequestParam("ids") List<Long> ids) {
        return R.ok(pdsTestOrganizationRangeService.deleteByIds(ids));
    }

}